---
title: "Validation - Japanese"
author: "`r Sys.info()['user']`"
date: "`r format(Sys.time(), '%Y-%m-%d')`"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.width = 10, fig.height = 5)
require(quanteda)
require(LSX)
require(irr)
lss <- readRDS("lss_ja.RDS")
```

```{r}
toks_man <- readRDS("data_tokens_manual_ja.RDS")
dfmt_man <- dfm(toks_man, remove_padding = TRUE)

dat <- docvars(dfmt_man)
dat$lss <- predict(lss, newdat = dfmt_man)
```

```{r,  fig.height=5, fig.width=5}
gplots::plotmeans(lss ~ human, dat, ylim = c(-1.5, 1.5), main = "Japanese", font.main = 1,
                  xlab = "Human", ylab = "Machine",  barcol = "black")
```
```{r}
kripp.alpha(t(as.matrix(dat[paste0("code_", 1:3)])), "interval")
```


```{r fig.height=5, fig.width=8}
cor.test(dat$lss, dat$human, use = "pair")
agg_lss <- aggregate(
        list(lss = dat$lss),
        by = list(human = dat$human), 
        FUN = mean, na.rm = TRUE
        )
cor.test(agg_lss$lss, agg_lss$human, use = "pair")
```
